package com.neuedu.user.controller;

import java.io.FileNotFoundException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.neuedu.user.entity.Category;
import com.neuedu.user.entity.Content;
import com.neuedu.user.entity.ContentPlus;
import com.neuedu.user.service.CategoryService;
import com.neuedu.user.service.ContentService;

@RestController
@RequestMapping("/contentController")
public class ContentController {
	 @Autowired
	    private CategoryService service;
	 @Autowired
	    private ContentService cservice;
	 @RequestMapping("/getClassfiy")
	 //http://localhost:8090/contentController/getClassfiy
	 public List<Category> getClassfiy(){
		 return service.getClassfiy();
	 }
	 @PostMapping("/addContent")
	    public int addContent(Content u) {
	        //JSONObject jsonObject = new JSONObject();
	        System.out.println("这是前端传来的表单"+u);
	        return cservice.addContent(u);
	 }
	 @RequestMapping("/getContent")
	 //http://localhost:8090/contentController/getContent
	 public List<ContentPlus> getContent(){
		 return cservice.getContent();
	 }
	 @RequestMapping("/deleteContent")
	//http://localhost:8090/contentController/deleteContent
	 public int deleteContent(Content u) {
		 return cservice.deleteContent(u);
	 }
	 public Category getClassfiyById(Category c) {
		 return service.getClassfiyById(c);
	 }
	 @RequestMapping("/updateContent")
	 public int updateContent(Content u) {
		 return cservice.updateContent(u);
	 }
}
